package com.yb.guigu.pick.core.bean.event;

import lombok.Data;
import org.springframework.context.ApplicationEvent;
import org.springframework.core.ResolvableType;
import org.springframework.core.ResolvableTypeProvider;

import java.time.Clock;

/**
 * Copyright (C), 2022-2023, 姚兵
 * Author: 32210
 * Date: 2023/6/9 15:30
 * FileName: GuiguPickEvent
 * Description:
 */

public class GuiguPickEvent<T> extends ApplicationEvent implements ResolvableTypeProvider {
    private final T data;

    public GuiguPickEvent(Object source,T data) {
        super(source);
        this.data=data;
    }

    public GuiguPickEvent(Object source, Clock clock,T data) {
        super(source, clock);
        this.data=data;
    }


    public T getData() {
        return data;
    }


    @Override
    public String toString() {
        return getClass().getName() + "[source=" + source + ",data="+data+"]";
    }

    @Override
    public ResolvableType getResolvableType() {
        return ResolvableType.forClassWithGenerics(getClass(), ResolvableType.forClass(getData().getClass()));
    }
}

